package com.hctforgreen.greenservice.model;

import java.io.Serializable;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * 百度地址信息
 * 
 * @author denghb
 * 
 */
public class BaiduAddressEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	public String city;
	public String district;
	public String province;
	public String street;
	public String street_number;

	public static BaiduAddressEntity parse(JSONObject jsonObject)
			throws JSONException {
		BaiduAddressEntity addressEntity = new BaiduAddressEntity();
		if (jsonObject == null) {
			return addressEntity;
		}

		if (jsonObject.has("city")) {
			addressEntity.city = jsonObject.getString("city");
		}
		if (jsonObject.has("district")) {
			addressEntity.district = jsonObject.getString("district");
		}
		if (jsonObject.has("province")) {
			addressEntity.province = jsonObject.getString("province");
		}
		if (jsonObject.has("street")) {
			addressEntity.street = jsonObject.getString("street");
		}
		if (jsonObject.has("street_number")) {
			addressEntity.street_number = jsonObject.getString("street_number");
		}

		return addressEntity;
	}

}
